package co.wngb;

import org.openjdk.jcstress.annotations.*;
import org.openjdk.jcstress.infra.results.I_Result;

@JCStressTest
@State
@Outcome(id = "-1", expect = Expect.ACCEPTABLE, desc = "ok")
@Outcome(id = "42", expect = Expect.ACCEPTABLE, desc = "ok")
@Outcome(id = "0", expect = Expect.ACCEPTABLE_INTERESTING, desc = "nook")
public class Misplace {

    private int x, y;

    static class Composite {
        int x;

        public Composite(int x) {
            this.x = x;
        }

        public int getX() {
            return x;
        }
    }

    static class Holder<T> {
        T value;

        public Holder(T value) {
            this.value = value;
        }

        public void setValue(T value) {
            this.value = value;
        }

        public T getValue() {
            return value;
        }
    }

    Holder<Composite> h = new Holder<>(new Composite(-1));

    @Actor
    void a1() {
        h.setValue(new Composite(42));
    }

    @Actor
    void observer(I_Result r) {
        r.r1 = h.getValue().getX();
    }

}
